export default {
    //存储数据
    state: {
        isCollapse: false,
        currentMenu: null,
        tabsList: [
        {
            url: '/',
            menuCode: 'home',
            menuName: '首页',
            icon: 'home'
        }
    ]
    },
    //调用方法
    mutations: {
        collapseMenu(state) {
            state.isCollapse = !state.isCollapse
        },
        //选择标签
        selectMenu(state, val) {
            if (val.menuCode === 'home') {
                state.currentMenu = null
            } else {
                state.currentMenu = val
                //如果等于-1说明tabsList不存在那么插入，否则什么都不做
                let result = state.tabsList.findIndex(item => item.menuCode === val.menuCode)
                result === -1 ? state.tabsList.push(val) : ''

            }
        },
        //关闭标签
        closeTab(state, val) {
            let result = state.tabsList.findIndex(item => item.menuCode === val.menuCode)
            state.tabsList.splice(result, 1)
        },
    },
    actions: {}
}
